import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:qyou_app/page/channel/live.dart';
import 'package:qyou_app/page/init/start.dart';
import 'package:qyou_app/page/portal/channel/channel.dart';
import 'package:qyou_app/page/portal/home/home.dart';
import 'package:qyou_app/page/portal/index.dart';

import 'common/bloc.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // 强制竖屏
  SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown
  ]);
  // 设置状态栏顶部和底部样式
  SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(statusBarColor: Colors.transparent));
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MultiBlocProvider(
      providers: [
        BlocProvider<NavCubit>(create: (context) => NavCubit()),
        BlocProvider<CarouselCubit>(create: (context) => CarouselCubit()),
        BlocProvider<VideoCubit>(create: (context) => VideoCubit()),
        BlocProvider<VideoPageNoCubit>(create: (context) => VideoPageNoCubit()),
      ],
      child: ScreenUtilInit(
        builder: () => MaterialApp(
          title: '(ㄒoㄒ)~~you',
          theme: ThemeData(
            scaffoldBackgroundColor: Color.fromARGB(255, 255, 255, 255),
            primaryColor: Color(0xFFFB7299),
            textTheme: TextTheme(
              bodyText1: TextStyle(color: Colors.black),
            ),
            appBarTheme: AppBarTheme(
              textTheme: TextTheme(
                headline6: TextStyle(color: Colors.black, fontSize: 18),
                bodyText1: TextStyle(color: Colors.black),
              ),
            ),
          ),
          //onGenerateRoute: _getRoute(),
          routes: {
            "/": (context) => StartPage(),
            "/index": (context) => IndexPage(),
            "/home": (context) => HomePage(ModalRoute.of(context).settings.arguments),
            "/channel": (context) => ChannelPage(),
            "/live": (context) => LivePage(),
          },
        ),
      ),
    );
  }
}
